/**
 * @description USER的数据库操作
 * @author 盘古他爹
 */

import { UserModel } from "../../model/user"

// import { User } from "@/model/user"
import { WhereOptions, Filterable } from "sequelize"
// WhereOptions<any>
class UserService {
    //find
    async getUserInfo<I>(userInfo: WhereOptions<I>) {
        console.log("传递的:", userInfo);
        const res = await UserModel.findOne({
            where: userInfo,
            // attributes: ['userName', 'password', 'id', 'nickname', 'role','isDM','avatar','isGame','gameId']
        })
        console.log("数据库查询结果", res);
        return res

    }


    //register
  async  registerUser(user:any) {
        const res = await UserModel.create(user)
        console.log("数据库查询结果", res);
        return res
    }

    async updateUserInfo(id:number,options:any) {
      const res =   await UserModel.update(options, {
            where: {
              id
            }
          });
          console.log("res", res);
          
          return res
    }


}

export default new UserService()